
<% layout('/layouts/default.html', {title: '销假', libs: ['validate']}){ %>
<div class="main-content">
    <div class="box box-main">
        <#form:form id="inputForm" model="${testLeave}" action="${ctx}/test/leave/complete" method="post" class="form-horizontal">
        <div class="box-body">
            <#form:hidden path="tid"/>
            <#form:hidden path="taskId"/>
            <#form:hidden path="saveEntity" value="${testLeave.saveEntity}"/>
            <input type="hidden" id="totalTimeHidden" value="${testLeave.totalTime}"/>
            <input type="hidden" name="p_DT_realityStartTime" />
            <input type="hidden" name="p_DT_realityEndTime" />
            <div class="form-unit">${text('基本信息')}</div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required hide">*</span> ${text('申请人')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="user.userName" class="form-control" disabled="true"/>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required hide">*</span> ${text('申请时间')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="applyTime" dataFormat="datetime" class="form-control digits" disabled="true"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required">*</span> ${text('标题')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="title" class="form-control" disabled="true"/>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required">*</span> ${text('请假时长')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <div class="input-group">
									<span class="input-group-btn">
										<input id="totalTimeText" class="form-control time-input" type="text" disabled="true">
									</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required">*</span> ${text('开始时间')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="startTime" dataFormat="datetime" class="form-control" disabled="true"/>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required">*</span> ${text('结束时间')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="endTime" dataFormat="datetime" class="form-control" disabled="true"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="control-label col-sm-2" title="">
                            <span class="required">*</span> ${text('原因')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-10">
                            <#form:textarea path="reason" rows="4" maxlength="500" class="form-control" disabled="true"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-unit">${text('销假信息')}</div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required">*</span> ${text('实际开始时间')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="realityStartTime" readonly="true" maxlength="20" class="form-control laydate required"
                            dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required">*</span> ${text('实际结束时间')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="realityEndTime" readonly="true" maxlength="20" class="form-control laydate required"
                            dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
                        <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
                    </div>
                </div>
            </div>
        </div>
    </#form:form>
</div>
</div>
<% } %>
<script src="${ctxStatic}/activiti.6.0/js/activiti.js"></script>
<script>
    $(function () {
        var totalTime = $("#totalTimeHidden").val();
        var dateSub = formatTotalDateSub(totalTime);
        $("#totalTimeText").val(dateSub);
    });
    $("#inputForm").validate({
        submitHandler: function(form){
            $('input[name="p_DT_realityStartTime"]').val($('input[name="realityStartTime"]').val());
            $('input[name="p_DT_realityEndTime"]').val($('input[name="realityEndTime"]').val());
            js.ajaxSubmitForm($(form), function(data){
                js.showMessage(data.message);
                if(data.result == Global.TRUE){
                    js.closeCurrentTabPage(function(contentWindow){
                        contentWindow.page();
                    });
                }
            }, "json");
        }
    });
</script>